# _*_ coding:utf-8 _*_
import csv

import pymysql

aFile = open('E:\Studygit\python_learning\GetBankInfo\code\/filter.csv', 'r', encoding='utf8')
aInfo = csv.reader(aFile)

bfile = open('E:\Studygit\python_learning\GetBankInfo\code\/ft.csv', 'r', encoding='utf8')
bInfo = csv.reader(bfile)

# print(rows)
connection = pymysql.connect(host='192.168.11.23', user='root', passwd='123456', port=30306,
                             db='bank', charset="utf8")
num = 0
for a, b in zip(aInfo, bInfo):

   for d, c in zip(a[4],b[0]):
       num = num + 1
       if d == c:

        print(num,a[0], a[1], a[2], a[3], a[4], b[1], b[2])
        branch_id = a[0]
        branch_name = a[1]
        branch_tel = a[2]
        bank_zip = a[3]
        bank_address = a[4]
        longitude = b[1]
        latitude = b[2]
        sql = "replace into bankinfo(branch_id, branch_name, branch_tel, bank_zip, bank_address, longitude, latitude) values('%s', '%s', '%s', '%s', '%s', '%s', '%s')" % (
            branch_id, branch_name, branch_tel, bank_zip, bank_address, longitude, latitude)

        cursor = connection.cursor()

        print(sql)
        cursor.execute(sql)
        connection.commit()
